<%--
  Created by IntelliJ IDEA.
  User: asd73
  Date: 2017/9/22
  Time: 17:37
  To change this template use File | Settings | File Templates.
--%>
<%--点击按钮显示和隐藏信息--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <title>Title</title>
    <style type="text/css">
        *{ margin: 0;padding: 0;list-style: none;}
        .con { width: 600px;
            margin: 100px auto;
            border:1px solid #100;
            padding: 10px;}
        .con ul li{width: 200px;
            float: left;text-align: center;
            height: 25px;
            line-height: 25px;}
        .con ul{
            overflow: hidden;}
        .con .btn {
            width: 200px;height: 22px;line-height: 22px;dispay:block;
            border: 1px solid #000;text-decoration: none;
            color: #000;text-align: center;
            font-size: 12px;background: no-repeat 30px center;margin: 0 auto;}
    </style>
    <%--不能运行的代码，只做记录所用--%>
    <script type="text/javascript">
        $(function (e) {
            //在页面加载完成后 先让li从第三个开始到最后（除了最后一个）隐藏起来
            var myLi = $('.con ul li:gt(2):not(:last)');
            myLi.hide()
            $('.btn').click(function () {
                if($(this).html() == '显示所有内容'){
                    //1:li标签slideDown 2:文字变隐藏所有内容
                    myLi.stop().slideDown();
                    $(this).html('隐藏所有内容')
                }else {
                    myLi.stop().slideUp();
                    //$(this).css('background-image',
                    $(this).html('显示所有内容')
                }
            })
        })
    </script>
</head>
<body>
    <div class="con">
        <ul>
            <li>佳能</li>
            <li>索尼</li>
            <li>三星</li>
            <li>尼康</li>
            <li>松下</li>
            <li>卡西欧</li>
            <li>富士</li>
            <li>柯达</li>
            <li>宾得</li>
            <li>理光</li>
            <li>奥林巴斯</li>
            <li>明基</li>
            <li>其他品牌</li>
        </ul>
        <a href="javascript:;" class="btn">显示所有内容</a>
    </div>
</body>
</html>
